<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "repair".
 *
 * @property int $id
 * @property string $name 名称
 * @property int $area_id 所属区域id
 * @property string $star_avg 平均得分
 * @property string $voltage_level 电压等级
 * @property string $service_type 服务类型
 * @property string $desc 介绍
 * @property int $type 类型(1:抢修队  2:施工单位)
 * @property int $status 状态
 * @property int $created_at 创建时间
 */
class Repair extends Base
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'repair';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['area_id', 'type', 'status', 'created_at'], 'integer'],
            [['star_avg'], 'number'],
            [['desc'], 'string'],
            [['name', 'voltage_level', 'service_type'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'area_id' => 'Area ID',
            'star_avg' => 'Star Avg',
            'voltage_level' => 'Voltage Level',
            'service_type' => 'Service Type',
            'desc' => 'Desc',
            'type' => 'Type',
            'status' => 'Status',
            'created_at' => 'Created At',
        ];
    }

    public function getArea(){
        return $this->hasOne(Area::class, ['id' => 'area_id']);
    }
}
